package com.accloud.service;

import java.util.ArrayList;
import java.util.Iterator;

public class ACPushTable {
    public static final int OPTYPE_CREATE = 1;
    public static final int OPTYPE_DELETE = 8;
    public static final int OPTYPE_REPLACE = 2;
    public static final int OPTYPE_UPDATE = 4;
    protected String className;
    protected int opType;
    protected ACObject primaryKey;

    public ACPushTable() {
    }

    public ACPushTable(String className2, ACObject primaryKey2) {
        this.className = className2;
        this.primaryKey = primaryKey2;
    }

    public ACPushTable(String className2, ACObject primaryKey2, int opType2) {
        this.className = className2;
        this.primaryKey = primaryKey2;
        this.opType = opType2;
    }

    public String getClassName() {
        return this.className;
    }

    public void setClassName(String className2) {
        this.className = className2;
    }

    public ACObject getPrimaryKey() {
        return this.primaryKey;
    }

    public void setPrimaryKey(ACObject primaryKey2) {
        this.primaryKey = primaryKey2;
    }

    public void setOpType(int opType2) {
        this.opType = opType2;
    }

    public int getOpType() {
        return this.opType;
    }

    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        ACPushTable pushTable = (ACPushTable) o;
        if (pushTable.className == null || this.className == null || !pushTable.className.equals(this.className)) {
            return false;
        }
        return (pushTable.primaryKey == null || this.primaryKey == null || !pushTable.primaryKey.equals(this.primaryKey)) ? false : true;
    }

    public String toString() {
        return "ACPushTable{className='" + this.className + "', primaryKey=" + this.primaryKey + ", opType=" + this.opType + '}';
    }

    public static String getOpDescription(int opType2) {
        ArrayList<String> ops = new ArrayList<>();
        if ((opType2 | 1) != 0) {
            ops.add("新增");
        }
        if ((opType2 | 2) != 0) {
            ops.add("替换");
        }
        if ((opType2 | 4) != 0) {
            ops.add("更新");
        }
        if ((opType2 | 8) != 0) {
            ops.add("删除");
        }
        StringBuilder builder = new StringBuilder();
        Iterator<String> it = ops.iterator();
        while (it.hasNext()) {
            String s = it.next();
            if (builder.length() > 0) {
                builder.append(", ");
            }
            builder.append(s);
        }
        return builder.toString();
    }
}
